package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mr.Abel
 * @since 2024-12-31
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService iUsersService;

    //注册
    @PostMapping("/register")
    public String register(@RequestBody User user){
            iUsersService.addUser(user);
            return ("注册成功");
    }

    // 登录
    @PostMapping("/login")
    public String login(@RequestBody User user){
        if (iUsersService.addUser(user)){
            return "登录成功";
        }
        return "登录失败";
    }


    //添加商品
    @PostMapping("/add")
    public String add(){
        return "添加成功";
    }

}
